<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BaseLogic
 *
 * @author Administrator
 */
class BaseLogic extends ParentClass{
    protected $table;
    public function __construct() {
        parent::__construct();
    }
     /**
     *    保存和更新
     * @param type $data 保存信息
     * @param type $id   id
     * @return type  
     */
     public function save($data,$id=0){
        if($id>0){
            $res=  $this->table->update($data,"id={$id}");
        }else{
            $res=$this->table->insert($data,TRUE);
        }
        return $res;
    }
    public function getOne($where){
        return $this->table->get_one("*",$where);
    }

    /**
     * 获得数据
     * @return type 所有数据
     */
    public function getAll(){
        $res=  $this->table->select("*");
        return $res;
    }
    /**
     * 清空表
     * @return type 返回执行结果
     */
    public function deleteAll(){
        $res=  $this->table->delete();
        return $res;
    }
    //执行sql函数
    public function query($sql){
        return $this->table->query($sql);
    }
    //执行sql函数
    public function execute($sql){
        return $this->table->execute($sql);
    }
        /**
     * 事物begin
     */
    public function begin(){
        $this->table->begin();
    }
    //回滚
     public  function rollback(){
         $this->table->rollback();
     }
      //执行事务commit  
    public  function commit(){
        $this->table->commit();

    }
     
     
     
     
}
